package com.kedacom.freedomLabel.viewmodel.category;


import com.kedacom.freedomLabel.Options;
import com.kedacom.freedomLabel.base.BaseViewModel;
import com.kedacom.freedomLabel.initdata.bean.CategoryNewBean;
import com.kedacom.freedomLabel.model.bean.Category;
import com.kedacom.freedomLabel.utils.Cn2Spell;
import com.kedacom.lego.message.LegoMessageManager;
import com.kedacom.lego.mvvm.ObservableLiveDataField;

public class NewCategoryControlViewModel extends BaseViewModel {

    public ObservableLiveDataField<String> rubbishName = new ObservableLiveDataField<>();


    public void saveID() {
        CategoryNewBean item = new CategoryNewBean();
        item.name = rubbishName.getValue();
        item.shortHand = Cn2Spell.getPinYinHeadChar(item.name);
        item.createTime = System.currentTimeMillis();
        LegoMessageManager.getInstance().sendMessage(Options.MSG_ADD_ITEM, item);
    }

    public void updateID(CategoryNewBean item) {

        item.name = rubbishName.getValue();
        item.shortHand = Cn2Spell.getPinYinHeadChar(item.name);
        item.createTime = System.currentTimeMillis();
        LegoMessageManager.getInstance().sendMessage(Options.MSG_SAVE_ITEM, item);
    }
}